package org.chen.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Section implements Serializable {
    @Serial
    private static final long serialVersionUID = 4L;
    private String heading;  // 小标题
    private String headingUrl;   // 标题中的链接URL（如果有）
    private String headingTeam;  // 链接中的球队名（如果有）
    private List<String> paragraphs;  // 该小标题下的段落

    // 添加内容处理方法
    public void processContent(Function<String, String> contentProcessor) {
        if (heading != null) {
            heading = contentProcessor.apply(heading);
        }
        if (headingTeam != null) {
            headingTeam = contentProcessor.apply(headingTeam);
        }
        if (paragraphs != null) {
            paragraphs = paragraphs.stream()
                    .map(contentProcessor)
                    .collect(Collectors.toList());
        }
    }
}
